﻿namespace Digitalmes.Core.Common.SerialPorts;

/// <summary>
/// RS232 串口
/// </summary>
public interface IRsSerialPort
{
    /// <summary>
    /// 用途
    /// </summary>
    string? Purpose { get; }

    /// <summary>
    /// 串口名称
    /// </summary>
    string PortName { get; }

    /// <summary>
    /// 检测串口是否已开启
    /// </summary>
    bool IsOpen { get; }

    /// <summary>
    /// 开启串口
    /// </summary>
    /// <remarks>串口找不到时，仅在 Open() 时会抛异常（System.IO.FileNotFoundException）, IsOpen、Close() 和 Dispose() 都正常。</remarks>
    void Open();

    /// <summary>
    /// 关闭串口
    /// </summary>
    void Close();
}
